import localization
import util

class LocalizationSafeString(unicode):

    def replace(self, old, new, maxreplace = 0):
        return LocalizationSafeString(unicode.replace(self, old, new, maxreplace))



    def __add__(self, other):
        return LocalizationSafeString(unicode.__add__(self, other))



    def __iadd__(self, other):
        return LocalizationSafeString(unicode.__add__(self, other))



    def join(self, iterable):
        return LocalizationSafeString(unicode.join(self, iterable))




def IsHardcodedString(text):
    import localizationUtil
    isHardcoded = (not isinstance(text, localizationUtil.LocalizationSafeString))
    if isHardcoded:
        pass
    return isHardcoded



def WrapHardcodedString(text, color = '0xaaff00ff'):
    text = ('<color=%s>^_%s_^</color>' % (color, text))
    return LocalizationSafeString(text)



def SetHardcodedStringDetection(isEnabled):
    localization.hardcodedStringDetectionIsEnabled = isEnabled
    prefs.showHardcodedStrings = isEnabled



def IsHarcodedStringDetectionEnabled():
    return localization.hardcodedStringDetectionIsEnabled


exports = util.AutoExports('localizationUtil', locals())

